package cn.edu.gdpt.mobile0123456789lu0501;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainWrite;
    private TextView tvMainRead;
    private FrameLayout frameLayou;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initFragment();
        tvMainWrite.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                tvMainWrite.setBackgroundColor(Color.GRAY);
                tvMainRead.setBackgroundColor(Color.WHITE);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.frameLayou,new FileWriteFragment())
                        .commit();
            }
        });
        tvMainRead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                tvMainWrite.setBackgroundColor(Color.WHITE);
                tvMainRead.setBackgroundColor(Color.GRAY);
                getSupportFragmentManager().beginTransaction()
                        .replace(R.id.frameLayou,new FileReadFragment())
                        .commit();
            }
        });
    }

    private void initView() {
        tvMainWrite = (TextView) findViewById(R.id.tvMainWrite);
        tvMainRead = (TextView) findViewById(R.id.tvMainRead);
        frameLayou = (FrameLayout) findViewById(R.id.frameLayou);
    }
    private void initFragment(){
        getSupportFragmentManager().beginTransaction()
                .add(R.id.frameLayou,new FileWriteFragment())
                .commit();
    }

}